package zym.servlet;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DeptDAO;
import dao.DutyDAO;
import dao.EmpDAO;
import dao.impl.DeptDAOImpl;
import dao.impl.DutyDAOImpl;
import dao.impl.EmpDAOImpl;

import model.Dept;
import model.Duty;
import model.Emp;
import model.EmpTransfer;

import util.Page;
import zym.service.*;
public class TransferServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int pageNo=1;
		int pageSize=5;
		Page page=null;
		TansferMag tf = new TansferMag();
		try{
			if(request.getParameter("pageNo")!=null)
			{
				pageNo=Integer.parseInt(request.getParameter("pageNo"));
			}
			if(request.getParameter("pageSize")!=null)
			{
				pageSize=Integer.parseInt(request.getParameter("pageSize"));
				request.getSession().setAttribute("pageSize", pageSize);
			}
			if(request.getSession().getAttribute("pageSize")!=null)
			{
				pageSize=(Integer) request.getSession().getAttribute("pageSize");
			}
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		
		page=tf.getAll(pageNo,pageSize);
		request.setAttribute("page", page);
		
		request.getRequestDispatcher("/Transfer/show_transfer.jsp").forward(request, response);
	}

}
